﻿@model dai_hoc_tuong_lai.Models.ContactModel
@{  AjaxOptions ajaxOpts = new AjaxOptions
    {
        HttpMethod = "post",
        OnComplete = "completedAjaxRequestContact"
    };
}
<script type="text/javascript">

    function completedAjaxRequestContact(obj) {

        var returnObj = eval('(' + obj.responseText + ')');

        if (returnObj.Status == "success") {
            makeSuccessHighlightContact("Bạn đã gửi liên hệ với chúng tôi thành công ! chúng tôi sẽ liên lạc với bạn trong thời gian sớm nhất .")
        } else {
            makeErrorHighlightContact(returnObj.Message);
        }

        return false;
    }

    function makeErrorHighlightContact(messageStr) {
        var $highlight = $("<div style='padding: 0.7em; margin-bottom:5px; width: inherit;'><p><span class='ui-icon ui-icon-alert' style='float: left; margin-right: .3em;'></span><strong>Lỗi: </strong>" + messageStr + "</p></div>");
        $highlight.addClass("ui-state-highlight ui-corner-all");
        $highlight.prependTo(".warning-area-contact");
        $highlight.delay(4000).fadeOut(500);
    }

    function makeSuccessHighlightContact(messageStr) {
        var $highlight = $("<div style='padding: 0.7em; line-hight:25px; margin-bottom:5px; width: inherit;'><p style='line-height: 25px;'><span class='ui-icon ui-icon-info' style='float: left; margin-right: .3em;'></span><strong>Success: </strong>" + messageStr + "</p></div>");
        $highlight.addClass("ui-state-highlight ui-corner-all");
        $highlight.prependTo(".warning-area-contact");
        //$highlight.delay(4000).fadeOut(500);
    }

    

</script>
@using (Ajax.BeginForm("Formlienhe", "Home", null, ajaxOpts, new { enctype = "multipart/form-data" }))
{
    <table border="0" cellpadding="7" cellspacing="7" style="width:90%; margin:20px">
        <tbody>
            <tr>
                <td colspan="2">
                   <h2> Liên hệ với chúng tôi </h2>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <div class="warning-area-contact">
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <label for="">
                        Tên người gửi <span class="require">( * )</span>
                    </label>
                    <br>
                    @Html.TextBoxFor(model => model.Name, new { @class ="inputetxt" })
                </td>
                <td>
                    <label for="">
                        Email <span class="require">( * )</span>
                    </label>
                    <br>
                    @Html.TextBoxFor(model => model.Email, new { @class ="inputetxt" })
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <label for="">
                        Số điện thoại <span class="require">( * )</span>
                    </label>
                    <br>
                    @Html.TextBoxFor(model => model.Dt, new { @class ="inputetxt" })
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <label for="">
                        Nội dung gửi <span class="require">( * )</span>
                    </label>
                    <br>
                    @Html.TextAreaFor(model => model.NoiDung, new { @class = "TextAreainputetxt", rows = "8", cols = "38", style="width:570px" })
                </td>
            </tr>
            <tr>
                <td colspan="2" style="vertical-align: bottom; padding-bottom: 3px; padding-top: 5px;">
                    <input type="submit"  value="Gửi liên hệ" class="btContact">
                </td>
            </tr>
        </tbody>
    </table>
}